package pro.shuangxi.common.utils;

        import org.springframework.beans.BeansException;
        import org.springframework.beans.factory.BeanFactory;
        import org.springframework.beans.factory.BeanFactoryAware;
        import org.springframework.stereotype.Component;

/**
 * @author ：mengshx
 * @date ：Created in 2021/4/11 21:08
 * @description：
 */
@Component
public class SpringUtils implements BeanFactoryAware {
    BeanFactory factory=null;
    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.factory = beanFactory;
    }

    public Object getBean(String beanName) {
       return factory.getBean(beanName);
    }
    public  <T> T getBean(Class<T> clazz) {
       return factory.getBean(clazz);
    }
}
